//Compass Component Constructor
function Compass(e) {
	
	var self = Ti.UI.createView({
		height: e.containerheight,
		width: e.containerwidth
		//center: { x: e.width*0.5 , y: e.height*0.5}
		
	});
	
	//create the compass view
	var top = Ti.UI.createImageView({
  		image:'/ui/common/images/compass_top.png',
  		height: self.height,
  		//center: { x: e.width*0.5 , y: e.height*0.5} ,
  		zIndex: 2
	});
	
	self.add(top);
	
	var bottom = Ti.UI.createImageView({
		image: '/ui/common/images/compass_bottom.png',
		//width: top.width,
		height: self.height,
  		//center: { x: e.width*0.5 , y: e.height*0.5} ,
  		zIndex: 1
	});
	
	self.add(bottom);
	
	//global listener for HUD messages
	Ti.App.addEventListener('newHUDdata', function(evt) {		
		Titanium.API.log("debug","new HUD data event recieved");
		
		var matrix2d_rotate = Ti.UI.create2DMatrix();
		matrix2d_rotate = matrix2d_rotate.rotate(evt.yaw);
		animation = Ti.UI.createAnimation({
			transform: matrix2d_rotate,
			duration: 1
		});
		
		bottom.animate(animation);
	});
	
	//start the hudActivity in the comms module
	Ti.App.fireEvent('startHUD');
	
	return self;
}

//make constructor function the public component interface
module.exports = Compass;